<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FlyGreenwich's Aircraft</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<%
if(session.getAttribute("admin_id")== null || session.getAttribute("admin_id").equals("")){
%>
window.location = "http://localhost:8080/FlyGreenwichAirline/admin/login.jsp";
<%}%>

function validate(){
	
	if(document.getElementById("depart").value.length==0){
		alert("Please key in your departure. ");
		return false;
	}else if(document.getElementById("dest").value.length==0){
		alert("Please key in your destination. ");
		return false;
	}else if(document.getElementById("price").value.length==0){
		alert("Please key in your price. ");
		return false;
	}else if(document.getElementById("date").value.length==0){
		alert("Please key in your date. ");
		return false;
	}else if(document.getElementById("time").value.length==0){
		alert("Please key in your time. ");
		return false;
	}else{
		return true;
	}
}

var startyear = "2011"; // Change the Starting year in your dropdown
var endyear = "2060";  // Change th ending year in the dropdown

function selectdate() {
var mon = document.addflight.month.options[document.nday.month.selectedIndex].value;
var day = document.addflight.day.options[document.nday.day.selectedIndex].value;
var year = document.addflight.year.options[document.nday.year.selectedIndex].value;
}
</script>
</head>
<body>
<a name="top" id="top"></a>
<center>
	<jsp:include page="/WEB-INF/pages/admin_menu.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/pages/header.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/pages/admin_content.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/pages/admin_sidebar.jsp"></jsp:include>
	<div id="mainbar">
		<h1><a name="css" id="css"></a>Add Flight</h1>
		<form id="addflight" action="addFlightServlet" name="addflight" method="post" onsubmit="return validate()">
			<span>Please take notes that the route only allow for Greenwich to other places, or from other places to Greenwich.</span>
			<table>
				<tr>
					<td>Departure :</td>
					<td colspan="2"><select id="adddeparture" name="adddeparture">
					<option value="Greenwich">Greenwich</option>
					<option value="Dublin">Dublin</option>
					<option value="Edinburgh">Edinburgh</option>
					<option value="Norwich">Norwich</option>
					<option value="Cardiff">Cardiff</option>
				</select></td>
				</tr>
				<tr>
					<td>Destination :</td>
					<td colspan="2"><select id="adddestination" name="adddestination">
							<option value="Cardiff">Cardiff</option>
							<option value="Dublin">Dublin</option>
							<option value="Edinburgh">Edinburgh</option>
							<option value="Norwich">Norwich</option>
							<option value="Greenwich">Greenwich</option>
						</select></td>
				</tr>
				<tr>
					<td>Price :</td>
					<td colspan="2">$ <input type="text" id="price" name="price" size="10"/></td>
				</tr>
				<tr>
					<td>Date :</td>
					<td align="center">Day
						<select name="day" size="1">
							<script type="text/javascript">
								for(var j=1;j<32;j++)
									document.write("<option value="+j+">"+j+"</option>");
        					</script>
						</select>
					</td>
					<td align="center">Month
	    				<select name="month" size="1">
	    					<script type="text/javascript">
								for(var i=1;i<13;i++)
									document.write("<option value="+i+">"+i+"</option>");
	    					</script>
        				</select>
        			</td>
					<td align="center">Year
						<select name="year" size="1">
							<script type="text/javascript">
								for(var k=startyear;k<endyear;k++)
									document.write("<option value="+k+">"+k+"</option>");
       						 </script>
        				</select>
        			</td>
				</tr>
				<tr>
					<td>Depart Time :</td>
					<td>
						<select id="time" name="time">
							<option value="0900">09:00 AM</option>
							<option value="1000">10:00 AM</option>
						</select>
					</td>
				</tr>
				<tr>
					<td colspan="2"><input type="submit" value="Add" onclick="selectdate()"/></td>
				</tr>
			</table>
		</form>
    </div>
    <br><br><br><br><br><br><br><br><br><br>
	<jsp:include page="/WEB-INF/pages/footer.jsp"></jsp:include>
</center>
</body>
</html>
